package com.simple.editor.action.impl;

import com.simple.editor.ApplicationContext;
import com.simple.editor.ui.ChangesPane;
import com.simple.editor.ui.FileModel;
import com.simple.editor.ui.MenuPane;
import com.simple.editor.ui.TabbedEditorPane;

/**
 * {@link ModifyEditorUIAction} handles user "Modify File" action.
 * <p/>
 * Created with IntelliJ IDEA.
 * User: vsoroka
 * Date: 05.06.13
 * Time: 16:39
 * To change this template use File | Settings | File Templates.
 */
public class ModifyEditorUIAction extends AbstracEditorUIAction {

    private final ApplicationContext ctx;

    public ModifyEditorUIAction(final ApplicationContext ctx) {
        this.ctx = ctx;
    }

    @Override
    public void perform(final FileModel... files) {
        if (files != null && files.length > 0) {
            for (final FileModel file : files) {
                file.setChanged(true);
            }
            ctx.getComponent(MenuPane.class).enableSaveAllButton();
            ctx.getComponent(ChangesPane.class).refreshTree();
            ctx.getComponent(TabbedEditorPane.class).syncLabelStyle(files);
        }
    }
}

